package com.gyh.modules.test;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
* @author 作者 gyh:
* @version 创建时间：2018年1月7日 下午7:59:36
* 
*/
public class AppTest24 {

	public static void main(String[] args) {
		List<User> list = new ArrayList<User>();
        User user1 = new User("第一位","用户1");
        list.add(user1);
        User user2 = new User("第二位","用户2");
        list.add(user2);
        User user3 = new User("第三位","用户3");
        list.add(user3);
        Optional<User> uu = list.stream().filter( User -> User.getMessage().equals("用户1")).findAny();
        
        System.out.println(uu.get().getOrder());
	}
}

 class User {
    String order;
    String message;
    
    public User(String order, String message) {
       this.order = order;
       this.message = message;
   }
   public String getOrder() {
       return order;
   }
   public void setOrder(String order) {
       this.order = order;
   }
   public String getMessage() {
       return message;
   }
   public void setMessage(String message) {
       this.message = message;
   }
   
}
